from utils import platform
from lib.config.index import wifi_config
from lib.log.index import wlan_logger

if platform.is_esp32_series():
    from lib.net.esp32 import *
elif platform.is_raspberry_pico_series():
    from lib.net.at import *

ssid = wifi_config.get_ssid()
password = wifi_config.get_password()
wifi_connect_status = 0


def do_connect():
    global wifi_connect_status
    if wifi_connect_status == 0:
        wlan_logger.log(f"connect {ssid}-{password}")
        connect_WIFI(ssid, password)
        wifi_connect_status = 1

def do_disconnect():
    global wifi_connect_status
    if wifi_connect_status == 0:
        pass


def is_connected():
    """是否已经连接上wifi"""
    global wifi_connect_status
    return wifi_connect_status == 1


def test_wifi_connect():
    pass

if __name__ == "__main__":
    do_connect()
    test_wifi_connect()
